package com.mrdeer.common.entity.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.mrdeer.common.base.Converter;
import com.mrdeer.common.entity.beans.PageEntity;
import com.mrdeer.common.entity.sys.Setting;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class SettingDTO extends Setting implements Converter<Setting, SettingDTO> {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private PageEntity page;

    @Override
    public void convert2Do(Setting setting) {
        BeanUtils.copyProperties(this, setting);
    }

    @Override
    public SettingDTO convert(Setting setting) {
        BeanUtils.copyProperties(setting, this);
        return this;
    }
}
